<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>文章列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="lib/layui/css/layui.css">
    <link rel="stylesheet" href="css/scroll-bar.css">
    <link rel="stylesheet" href="css/sub-page.css">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_693759_wytlyqhtdtj1nhfr.css">
    <link rel="stylesheet" href="lib/nprogress/nprogress.css">
</head>
<body>
<div style="display: none" id="noneDiv">
		<!--form表单-->
		<form class="layui-form layui-form-pane ok-form" id="formClass"
			action="UpdateProviderInfoAjax" method="post">
					<div class="layui-form-item">
				<label class="layui-form-label">订单编号</label>
				<div class="layui-input-block">
					<input type="text" id="ProviderID" name="ProviderID"
						placeholder="" autocomplete="off" class="layui-input"
						lay-verify="required" >
				</div>
			</div>
			<!-- <div class="layui-form-item">
				<label class="layui-form-label">ID</label>
				<div class="layui-input-block">
					<input type="text" id="providerID" name="providerID"
						placeholder="请输入用户名" autocomplete="off" class="layui-input"
						lay-verify="required" >
				</div>
			</div> -->
			<div class="layui-form-item">
				<label class="layui-form-label">商品名称</label>
				<div class="layui-input-block">
					<input type="text" id="cargoName" name="cargoName"
						placeholder="请输入用户名" autocomplete="off" class="layui-input"
						lay-verify="required" >
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">单价</label>
				<div class="layui-input-block">
					<input type="text" id="ProviderName" name="ProviderName"
						placeholder="请输入用户名" autocomplete="off" class="layui-input"
						lay-verify="required" >
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">数量</label>
				<div class="layui-input-block">
					<input type="text" name="ProviderTel" placeholder="请输入用户名"
						autocomplete="off" class="layui-input" lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">小计</label>
				<div class="layui-input-block">
					<input type="text" name="ProviderAddress" placeholder="请输入用户名"
						autocomplete="off" class="layui-input" lay-verify="required">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">供货日期</label>
				<div class="layui-input-block">
					<input type="text" name="ProviderDate"
						placeholder="请选择出生日期 格式为yyyy-MM-dd HH:mm:ss" autocomplete="off"
						class="layui-input" id="birthday" lay-verify="birthdayVerify">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="editInfo"
						id="editInfo">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</div>
<div class="ok-body">
    <!--面包屑导航区域-->
    <div class="ok-body-breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>首页</cite></a>
                <a><cite>常用页面</cite></a>
                <a><cite>文章列表</cite></a>
            </span>
        <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);" title="刷新">
      <!--       <i class="layui-icon layui-icon-refresh"></i> -->刷新
        </a>
    </div>
    <!--模糊搜索区域-->
    <div class="layui-row">
        <form class="layui-form layui-col-md12 ok-search" >
          <!--   <input class="layui-input" placeholder="开始日期" autocomplete="off" id="startTime">
            <input class="layui-input" placeholder="截止日期" autocomplete="off" id="endTime"> -->
            <input class="layui-input" placeholder="请输入订单标号" autocomplete="off" id="orderId" >
            <button class="layui-btn" lay-submit="" lay-filter="search"  id="search">
                <!-- <i class="layui-icon layui-icon-search"></i> -->查询
            </button>
        </form>
    </div>
    <!--工具栏-->
    <okToolbar>
        <button class="layui-btn layui-btn-normal" id="batchEnabled">
            <i class="iconfont icon-shangsheng"></i>生成订单
        </button>
       <!--  <button class="layui-btn layui-btn-warm" id="batchDisabled">
            <i class="iconfont icon-web-icon-"></i>批量下架
        </button>
        <button class="layui-btn layui-btn-danger" id="batchDel">
            <i class="layui-icon layui-icon-delete"></i>批量删除
        </button>
        <button class="layui-btn" id="addUser">
            <i class="layui-icon">&#xe61f;</i>添加文章
        </button> -->
        <span>共有数据：<i id="countNum"></i> 条</span>
    </okToolbar>
    <!--数据表格-->
    <table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
</div>
<!--js逻辑-->
<script src="lib/layui/layui.js"></script>
<script src="lib/nprogress/nprogress.js"></script>
<script>
    // 进度条加载提示
    NProgress.start();
    window.onload = function () {
        NProgress.done();
    }
    // layui相关
    layui.use(['element', 'table', 'form', 'jquery', 'laydate'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var laydate = layui.laydate;

        laydate.render({
            elem: '#startTime',
            type: "datetime"
        });

        laydate.render({
            elem: '#endTime',
            type: "datetime"
        });

        table.render({
            elem: '#tableId',
            url: 'adminOrder',
            limit: 10,
        	limits :[10,15,20,25,30,35],
            page: true,
            even: true,
            cols: [[
                {type: 'checkbox'},
                {field: 'id', title: 'ID', width: 80, sort: true},
                {field: 'name', title: '商品名称', width: 300},
                {field: 'consumerName', title: '收件人', width: 80},
                {field: 'Address', title: '收货地址', width: 200},
                {field: 'SinglePrice', title: '单价', width: 100},
                {field: 'onum', title: '数量', width: 100},
                {field: 'sum', title: '小计', width: 100},
                {field: 'orderDate', title: '订单生成日期', width: 200},
                {field: 'status', title: '订单状态', width: 200},
               /*  {field: 'isTop', title: '置顶', width: 100, templet: '#topTpl'},
                {field: 'status', title: '状态', width: 100, templet: '#statusTpl'}, */
               /*  {title: '操作', width: 200, templet: '#operationTpl', align: 'center'} */
            ]],
            done: function (res, curr, count) {
                $("#countNum").text(count);
            }
        });

       $("#search").click( function () {
            layer.msg('正在查询，请稍后...');
            var  startTime=$("#startTime").val();
            console.log("开始时间"+startTime);
            var  endTime=$("#endTime").val();
            console.log("结束时间"+endTime);
            var  orderId=$("#orderId").val();
            console.log("订单编号"+orderId);
            table.render({
                elem: '#tableId',
                url: "searchOrder?startTime="+startTime+"&endTime="+endTime+"&orderId="+orderId+"&temp=1",
                limit: 10,
            	limits :[10,15,20,25,30,35],
                page: true,
                even: true,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 80, sort: true},
                    {field: 'name', title: '商品名称', width: 300},
                    {field: 'consumerName', title: '收件人', width: 80},
                    {field: 'Address', title: '收货地址', width: 200},
                    {field: 'SinglePrice', title: '单价', width: 100},
                    {field: 'onum', title: '数量', width: 100},
                    {field: 'sum', title: '小计', width: 100},
                    {field: 'orderDate', title: '订单生成日期', width: 200},
                    {field: 'status', title: '订单状态', width: 200},
                   /*  {field: 'isTop', title: '置顶', width: 100, templet: '#topTpl'},
                    {field: 'status', title: '状态', width: 100, templet: '#statusTpl'}, */
                    {title: '操作', width: 200, templet: '#operationTpl', align: 'center'}
                ]],
                done: function (res, curr, count) {
                    $("#countNum").text(count);
                }
            });

            return false;
        });

        table.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'edit') {
                layer.open({
                    title: '编辑用户',
                    type: 2,
                    shade: false,
                    maxmin: true,
                    shade: 0.5,
                    area: ['90%', '90%'],
                    content: 'adminOrderEdit.jsp',
                    zIndex: layer.zIndex,
                    end: function () {
                        $(".layui-laypage-btn")[0].click();
                    }
                });
            } else if (layEvent === 'del') {
                layer.confirm("确定要删除吗？", {skin: 'layui-layer-lan', icon: 2, title: '提示', anim: 6}, function () {
                    layer.msg("操作成功！", {icon: 1, time: 1000});
                });
            }
        });

        $("#batchEnabled").click(function () {
            layer.confirm("确定生成订单吗？", {skin: 'layui-layer-lan', icon: 3, title: '提示', anim: 1}, function () {
                var checkStatus = table.checkStatus('tableId');
                var rows = checkStatus.data.length;
                var demo={datas:[]};
                if (rows > 0) {
                    var idsStr = "";
                    for (var i = 0; i < checkStatus.data.length; i++) {
                        idsStr += checkStatus.data[i].id + ',';
                        var temp={
                        		orderId:checkStatus.data[i].id,
                        	    cake:checkStatus.data[i].name,
                        	    ounitPrice:checkStatus.data[i].SinglePrice,
                        	    onum:checkStatus.data[i].onum,
                        	    ocost:checkStatus.data[i].sum,
                        		consumer:checkStatus.data[i].consumerName,   
                        		address:checkStatus.data[i].Address 
                        }
                        	demo.datas.push(temp);
                    }
                    var jsonString =JSON.stringify(demo);
                    $.ajax({
                    	type:"POST",
                    	url:"testOrer",
                    	data:"data="+jsonString,
                    	dataType:'JSON',
                    	success: function(msg){
   						console.log( "msg DEMO: " + msg );  						   
   					   }
                    })
                    console.log("选择的id-->" + idsStr);
                    layer.msg("操作成功！", {icon: 1, time: 1000}, function () {
                        $(".layui-laypage-btn")[0].click();
                    });
                } else {
                    layer.msg('未选择有效数据', {
                        offset: 't',
                        anim: 6
                    });
                }
            });
        })

        $("#batchDisabled").click(function () {
            layer.confirm("确定要批量下架吗？", {skin: 'layui-layer-lan', icon: 3, title: '提示', anim: 2}, function () {
                var checkStatus = table.checkStatus('tableId');
                var rows = checkStatus.data.length;
                if (rows > 0) {
                    var idsStr = "";
                    for (var i = 0; i < checkStatus.data.length; i++) {
                        idsStr += checkStatus.data[i].id + ',';
                    }
                    console.log("选择的id-->" + idsStr);
                    layer.msg("操作成功！", {icon: 1, time: 1000}, function () {
                        $(".layui-laypage-btn")[0].click();
                    });
                } else {
                    layer.msg('未选择有效数据', {
                        offset: 't',
                        anim: 6
                    });
                }
            });
        })

        $("#batchDel").click(function () {
            layer.confirm("确定要批量删除吗？", {skin: 'layui-layer-lan', icon: 2, title: '提示', anim: 6}, function () {
                var checkStatus = table.checkStatus('tableId');
                var rows = checkStatus.data.length;
                if (rows > 0) {
                    var idsStr = "";
                    for (var i = 0; i < checkStatus.data.length; i++) {
                        idsStr += checkStatus.data[i].id + ',';
                    }
                    console.log("选择的id-->" + idsStr);
                    layer.msg("操作成功！", {icon: 1, time: 1000}, function () {
                        $(".layui-laypage-btn")[0].click();
                    });
                } else {
                    layer.msg('未选择有效数据', {
                        offset: 't',
                        anim: 6
                    });
                }
            });
        })

        $("#addUser").click(function () {
            layer.open({
                title: '添加文章',
                type: 2,
                shade: false,
                maxmin: true,
                shade: 0.5,
                anim: 4,
                area: ['90%', '90%'],
                content: 'article-add.html',
                zIndex: layer.zIndex,
                // skin: 'layui-layer-molv',
                end: function () {
                    $(".layui-laypage-btn")[0].click();
                }
            });
        })
    })
</script>
<!--模板-->
<script type="text/html" id="urlTpl">
    <a href="{{d.url}}" target="_blank">{{d.url}}</a>
</script>
<script type="text/html" id="topTpl">
    <input type="checkbox" name="isTop" value="{{d.isTop}}" lay-skin="switch" lay-text="是|否" {{ d.isTop== true ? 'checked' : ''}}>
</script>
<script type="text/html" id="statusTpl">
    <input type="checkbox" name="top" value="{{d.status}}" lay-skin="switch" lay-text="上架|下架" {{ d.status== true ? 'checked' : ''}}>
</script>
<script type="text/html" id="operationTpl">
    <a href="javascript:;" title="编辑" lay-event="edit"><i class="layui-icon">&#xe642;</i></a>
    <a href="javascript:;" title="删除" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
</script>
</body>
</html>